package com.xinruke.hostels.reservation.controller;

import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import com.xinruke.hostels.reservation.interfaces.dto.*;
import com.xinruke.hostels.reservation.service.RoomOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author GuoZheng
 * @ClassName RoomController
 * @date：2019/6/19
 * @version: V1.0.0
 * @description：房间预订
 */
@RestController
@RequestMapping("/room-order/")
@Api(tags = "个人（房间）预订管理")
public class RoomOrderController extends BaseController {
    @Resource
    RoomOrderService roomOrderService;

    @PostMapping("/submit")
    @ApiOperation("提交")
    public ResultVO<String> submit(@Valid @RequestBody RoomOrderSubmitInfoDTO params) {
        return roomOrderService.submit(params);

    }

    /**
     * 取消订单
     */
    @PostMapping("/cancel")
    @ApiOperation("取消订单")
    public ResultVO<String> cancer(@Valid @RequestBody RoomOrderCancelDTO params) {
        return roomOrderService.cancel(params);
    }

    /**
     * 订单列表
     *
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("订单列表")
    public ResultVO<RowsDataVO<RoomOrderListQueryResultDTO>> list(@Valid @RequestBody RoomOrderListQueryDTO params) {
        return roomOrderService.list(params);
    }

    /**
     * 订单详情
     *
     * @return
     */
    @PostMapping("/detail")
    @ApiOperation("订单详情")
    public ResultVO<RoomOrderDetailQueryResultDTO> orderDetail(@Valid @RequestBody RoomOrderDetailQueryDTO params) {
        return roomOrderService.detail(params);
    }

    @PostMapping("/bookingOrderDetail")
    @ApiOperation("订单预订详情")
    public ResultVO<RoomOrderBookingDetailQueryResultDTO> getBookingOrderDetail(@RequestBody @Valid RoomOrderBookingDetailQueryDTO roomOrderBookingDetailQueryDTO) {
        ResultVO<RoomOrderBookingDetailQueryResultDTO> resultVO = ResultVO.success();

        RoomOrderBookingDetailQueryResultDTO roomOrderBookingDetailQueryResultDTO = roomOrderService.getBookingOrderDetail(roomOrderBookingDetailQueryDTO);
        resultVO.setData(roomOrderBookingDetailQueryResultDTO);

        return resultVO;
    }

}
